<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    
    <head>
        <meta charset="utf-8">
        <title>
            报价列表
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form">

            </form>
            <div class="x-body" id="bannerApp">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>
                            手机
                        </th>
                        <th>
                            姓名
                        </th>

                        <th>
                            楼盘
                        </th>

                        <th>
                            面积
                        </th>

                    </tr>
                    </thead>
                    <tbody id="productTable">

                    </tbody>
                </table>

                <div id="page"></div>
            </div>

        </div>
        <script src="/js/jquery-2.2.4.min.js" charset="utf-8">
        </script>
        <script src="/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="/js/x-layui.js" charset="utf-8">
        </script>
        <script src="/js/vue.js" charset="utf-8">
        </script>
        <script>


            $(document).ready(function () {
                listYusuan();
            });
            var imageFilename = '';
            layui.use(['form','layer', 'upload'], function(){
                $ = layui.jquery;
              var form = layui.form();
              var layer = layui.layer;

                layui.upload({
                    url: '/bo/common/upload.html', //上传接口
                    success: function(res){ //上传成功后的回调
                        imageFilename = res.data.filename;
                        $('#productImage').html('<img src="'+ res.data.imageUrl +'" width="100px" height="40px">');
                    }
                });

                var featurePro = [];
              //监听提交
//              form.on('submit(add)', function(data){
//
//                //发异步，把数据提交给服务器
//                  loadAnli();
//                return false;
//              });
            });

            var currentPage = 1;
            var totalPage = 0;
            
            function pageInfo() {
                layui.use(['laypage', 'layer'], function() {
                    var laypage = layui.laypage;
                    var layer = layui.layer;

                    laypage({
                        cont:'page' // 容器id
                        , pages: totalPage //总页数
                        , curr: currentPage
                        , jump: function (obj,first) {
                            currentPage = obj.curr;  //这里是后台返回给前端的当前页数

                            if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr  ajax 再次请求
                                listYusuan();
                            }
                        }
                    });

                });
            }

            function listYusuan() {
                $.ajax({
                    url: '/bo/listYusuan',
                    type: 'GET', //GET
                    async: true,    //或false,是否异步
                    data: {
                        currentPage : currentPage
                    },
                    timeout: 10000,    //超时时间
                    dataType: 'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                    success: function (ajaxData, textStatus, jqXHR) {
                        if (1000 != ajaxData.code) {
                            layer.alert(ajaxData.message, {icon: 5},function (index) {
                                layer.close(index);
                            });
                            return;
                        }

                        let msg = '';
                        let results = ajaxData.data.data;
                        for (let i=0;i<results.length;i++) {
                            msg += '                            <tr>\n' +
                                '                                <td>'+results[i].valueCase1+'</td>\n' +
                                '                                <td>'+results[i].valueCase2+'</td>\n' +
                                '                                <td>'+results[i].valueCase3+'</td>\n' +
                                '                                <td>'+results[i].valueCase4+'</td>\n' +
                                '                            </tr>';
                        }

                        totalPage = ajaxData.data.totalPage;
                        $('#productTable').html(msg);
                        pageInfo();
                    }
                });
            }

        </script>
        <script>

        </script>
    </body>

</html>